package com.itcast.jdbc;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Statement;

public class jdbcDemo1 {
    public static void main(String[] args) throws Exception {
        // 1.导入 jar 包
        // 2.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        // 3.获取数据库的连接对象
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db3", "root", "root");
        // 4.定义 sql 语句
        String sql = "UPDATE account SET balance = 500 WHERE id = 1";
        // 5.获取执行 sql 的对象 Statement
        Statement stmt = connection.createStatement();
        // 6.执行 sql
        int i = stmt.executeUpdate(sql);
        // 7.处理结果
        System.out.println(i);
        // 8.释放资源
        stmt.close();
        connection.close();

    }
}
